﻿@using Microsoft.AspNetCore.Components.Web;
@using Microsoft.JSInterop;
@using NewLife.Threading
@using ThingsGateway.Core.Extension;
@using BootstrapBlazor.Components
@namespace ThingsGateway.Debug

<Card HeaderText=@HeaderText class="mt-2 h-100" style="width:100%">
    <HeaderTemplate>
        <div class="flex-fill">
        </div>
        <Button Color="Color.None" style="color: var(--bs-card-title-color);" Icon=@(IsPause?"fa fa-play":"fa fa-pause") OnClick="Pause" />
        <Button IsAsync Color="Color.None" style="color: var(--bs-card-title-color);"  Icon=@("fa fa-sign-out") OnClick="HandleOnExportClick" />

    </HeaderTemplate>
    <BodyTemplate>
        <div style=@($"height:{HeightText};overflow-y:scroll")>
            <Virtualize Items="CurrentMessages??new  List<LogMessage>()" Context="itemMessage" ItemSize="60" OverscanCount=2>
                <ItemContent>
                    <div title=@itemMessage.Message.Substring(0, Math.Min(itemMessage.Message.Length, 500))
                         class=@(itemMessage.Level<(byte)Microsoft.Extensions.Logging.LogLevel.Information?"":
                         itemMessage.Level>=(byte)Microsoft.Extensions.Logging.LogLevel.Warning? " red--text ":"green--text ")
                         style="white-space: nowrap !important;overflow: hidden !important; text-overflow: ellipsis !important;">

                        @itemMessage.Message.Substring(0, Math.Min(itemMessage.Message.Length, 100))

                    </div>
                </ItemContent>
            </Virtualize>
        </div>

    </BodyTemplate>
</Card>



